<?php

namespace Apps\AppApi\Controllers;

use Phalcon\Mvc\Controller;
use PhalconPlus\Api\Common\AuthApi;
use PhalconPlus\Api\Common\AuthToken;

class IndexController extends Controller
{
    public function initialize()
    {
        $this->view->disable();
    }

    public function indexAction()
    {
        $this->view->enable();
        $this->assets->collection('header');
        $this->assets->collection('footer');
        $this->assets->addCss('libs/bootstrap-3.3.4/css/bootstrap.min.css');
        $this->assets->collection('footer')
            ->addJs('libs/jquery/jquery-2.1.3.min.js')
            ->addJs('libs/bootstrap-3.3.4/js/bootstrap.min.js');

        $this->tag->setTitle("API Test");
        $this->assets->addCss('css/appapi/main.css');
        $this->assets->collection('footer')
            ->addJs('libs/CryptoJS-v3.1.2/rollups/md5.js')
            ->addJs('libs/CryptoJS-v3.1.2/components/enc-base64-min.js')
            ->addJs('js/appapi/apiTest.js');
    }

    public function tokenAction()
    {
        $at = new AuthToken();
        $at->di = $this->di;
        $at->request = $this->request;
        $at->run();
        echo $at->response->getContent();
        //return $at->response;
    }

    public function apiAction()
    {
        $aa = new AuthApi();
        $aa->di = $this->di;
        $aa->request = $this->request;
        $aa->run();
        return $aa->response;
    }
   
    
    

}